<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
/**
 * 打印
 */
function dd() {
    array_map(function($x) { dump($x); }, func_get_args());
    exit;
}

/**
 * 统一返回信息
 * @param $code
 * @param $data
 * @param $msge
 */
function msg($code, $data, $msg)
{
    return compact('code', 'data', 'msg');
}

/*验证表单提交*/
function checksubmit($fieldname){
    $post = request()->param();
    //yun_dump($post[$fieldname]);
    if($post && isset($post[$fieldname])){
        $validate = new \think\Validate([
            ['__token__','require|token','来路错误|请勿重复提交'],
        ]);
        if(!$validate->check($post)){
            request()->token();
            showMessage($validate->getError());
        }
        return true;
    } else {
        return false;
    }
}